package com.cj.mobile.iabp.mvp.ui.activity;

import static com.jess.arms.utils.Preconditions.checkNotNull;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.TypedValue;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.cj.mobile.iabp.R;
import com.cj.mobile.iabp.app.utils.CommonUtils;
import com.cj.mobile.iabp.di.component.DaggerRemoveConcernInfoComponent;
import com.cj.mobile.iabp.mvp.contract.RemoveConcernInfoContract;
import com.cj.mobile.iabp.mvp.model.entity.RemoveInfo;
import com.cj.mobile.iabp.mvp.presenter.RemoveConcernInfoPresenter;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;

import butterknife.BindView;

/**
 * Created on 2025/10/01 10:19
 * 查看撤机关注信息
 *
 * @author Love_xie
 * module name is RemoveConcernInfoActivity
 */
public class RemoveConcernInfoActivity extends BaseActivity<RemoveConcernInfoPresenter> implements RemoveConcernInfoContract.View {
    @BindView(R.id.txvi_removeconcerninfo_code)
    TextView txviCode;                                                                              // 登记号
    @BindView(R.id.txvi_removeconcerninfo_name)
    TextView txviName;                                                                              // 患者姓名
    @BindView(R.id.txvi_removeconcerninfo_remove)
    TextView txviRemove;
    @BindView(R.id.txvi_removeconcerninfo_concern)
    TextView txviConcern;                                                                           // 关注
    @BindView(R.id.txvi_removeconcerninfo_removetime)
    TextView txviRemoveTime;                                                                        // 撤机时间

    @BindView(R.id.txvi_removeconcerninfo_azc)
    TextView txviAzc;                                                                              // 安装侧
    @BindView(R.id.txvi_removeconcerninfo_dc)
    TextView txviDc;                                                                               // 对侧

    @BindView(R.id.txvi_removeconcerninfo_ast)
    TextView txviAst;                                                                               // AST
    @BindView(R.id.txvi_removeconcerninfo_alt)
    TextView txviAlt;                                                                               // ALT
    @BindView(R.id.txvi_removeconcerninfo_cr)
    TextView txviCr;                                                                                // 肌酐
    @BindView(R.id.txvi_removeconcerninfo_egfr)
    TextView txviEgfr;                                                                              // eGFR
    @BindView(R.id.txvi_removeconcerninfo_myo)
    TextView txviMyo;                                                                               // 肌红蛋白
    @BindView(R.id.txvi_removeconcerninfo_clac)
    TextView txviClac;                                                                              // 乳酸cLac
    @BindView(R.id.txvi_removeconcerninfo_ga)
    TextView txviMyog;                                                                              // 肌钙蛋白
    @BindView(R.id.txvi_removeconcerninfo_zsszmqnj)
    TextView txviZsszmqnj;                                                                          // 左室舒张末期内径
    @BindView(R.id.txvi_removeconcerninfo_zssxfs)
    TextView txviZssxfs;                                                                            // 左室射血分数
    @BindView(R.id.txvi_removeconcerninfo_nirsl)
    TextView txviNirsL;                                                                             // NIRS左
    @BindView(R.id.txvi_removeconcerninfo_nirsr)
    TextView txviNirsR;                                                                             // NIRS右

    /*----------------------------------------------------------------业务信息----------------------------------------------------------------*/
    // 数据源
    private RemoveInfo info;
    // 患者姓名
    private String name;
    // 登记号
    private String code;

    /**
     * 根据主题使用不同的颜色。
     * 如果想要纯透明，则需要重写此方法，返回值为 -1 即可。
     */
    public int useStatusBarColor() {
        TypedValue typedValue = new TypedValue();
        getTheme().resolveAttribute(android.R.color.white, typedValue, true);
        return typedValue.data;
    }

    /**
     * 将状态栏改为浅色模式(状态栏 icon 和字体会变成深色)
     */
    public boolean useLightStatusBar() {
        return true;
    }

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerRemoveConcernInfoComponent
                .builder()
                .appComponent(appComponent)
                .view(this)
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.activity_remove_concern_info;
    }

    public void getBundleValues(Bundle bundle) {
        if (bundle != null) {
            info = bundle.getParcelable("info");
            code = bundle.getString("code");
            name = bundle.getString("name");
        }
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        setTitle("撤机关注信息");

        getBundleValues(getIntent().getExtras());

        loadData();
    }

    private void loadData() {
        if (info != null) {
            txviCode.setText(CommonUtils.isEmptyReturnStr(code, "暂无"));
            txviName.setText(CommonUtils.isEmptyReturnStr(name));
            txviRemove.setText(CommonUtils.isEmptyReturnStr(info.getRemoveType()));
            txviConcern.setText(CommonUtils.isEmptyReturnStr(info.getFocuse()));
            txviRemoveTime.setText(CommonUtils.isEmptyReturnStr(info.getRemoveTime()));

            txviAzc.setText(CommonUtils.isEmptyReturnStr(info.getLessL()));
            txviDc.setText(CommonUtils.isEmptyReturnStr(info.getLessR()));

            txviAst.setText(CommonUtils.isEmptyReturnStr(info.getAst()));
            txviAlt.setText(CommonUtils.isEmptyReturnStr(info.getAlt()));
            txviCr.setText(CommonUtils.isEmptyReturnStr(info.getCr()));
            txviEgfr.setText(CommonUtils.isEmptyReturnStr(info.getEgfr()));
            txviMyo.setText(CommonUtils.isEmptyReturnStr(info.getMyo()));
            txviClac.setText(CommonUtils.isEmptyReturnStr(info.getClac()));
            txviMyog.setText(CommonUtils.isEmptyReturnStr(info.getGa()));
            txviZsszmqnj.setText(CommonUtils.isEmptyReturnStr(info.getLeftSize()));
            txviZssxfs.setText(CommonUtils.isEmptyReturnStr(info.getLeftScore()));
            txviNirsL.setText(CommonUtils.isEmptyReturnStr(info.getNirsLeft()));
            txviNirsR.setText(CommonUtils.isEmptyReturnStr(info.getNirsRight()));
        }
    }

    @Override
    public Activity getActivity() {
        return this;
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }
}